﻿using LPLS.Commons.Enums;
using LPLS.Commons.Event;
using LPLS.DBEntities.ConfigModels.DataCollectionConfigModule.DataCollectionType.PLC;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LPLS.RuleEngineBaseCommon.CollectionVarRuleEngineModule
{
    /// <summary>
    /// 数据采集 变量配置  规则引擎配置
    /// </summary>
    public  class CollectionVarRuleEngineConfig : RuleEngineBaseWorkFlow<StatusEnum>
    {
        public CollectionVarRuleEngineConfig(string jsonname, Guid deviceID, Guid compentID, List<PLCVarPropertyConfig> pLCVarList) : base(jsonname, deviceID, compentID, pLCVarList)
        {



        }

        /// <summary>
        /// 执行相应的规则 
        /// </summary>
        /// <param name="t"></param>
        public override void HandleRuleResult(StatusEnum t)
        {
            // 发布数据采集 变量配置 这是已经搞好了的规则引擎
            CollectionVarRuleEngineEvent.PubshCollectionVarRuleEngine(t,DeviceID,CompentID, PLCVarList);
        }


       /// <summary>
       /// 处理数据
       /// </summary>
       /// <param name="data">采集到的数据</param>

        public void DealData(  Dictionary<string, object> data)
        {

          var myenum=   this.ExecuteRules<StatusEnum>(data);
            HandleRuleResult(myenum?? StatusEnum.Other);



        }

      
    }
}
